//
//  BLECMDItem.swift
//  TimeBoat
//
//  Created by Jun on 2022/9/8.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import Foundation

/// 命令数据
@objc class BLECMDItem: NSObject {
    /// 命令头
    @objc var header: UInt8 = 0
    /// 命令类型
    @objc var cmdType: UInt8 = 0
    /// 数据长度
    @objc var dataLen: Int = 0
    /// 设备时间戳(秒)
    @objc var timestampSecond: Int = 0
    /// 数据
    @objc var data: [UInt8]?
    
    init(header: UInt8, cmdType: UInt8, dataLen: Int, timestampSecond: Int, data: [UInt8]?) {
        self.header = header
        self.cmdType = cmdType
        self.dataLen = dataLen
        self.timestampSecond = timestampSecond
        self.data = data
    }
    
    @objc func toString() -> String {
        return "timestampSecond = \(timestampSecond), header = \(header.toHex()), cmdType = \(cmdType.toHex()), dataLen = \(dataLen.toHex()), data = \(String.toHexStr(buf: data))"
    }
}
